
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

/**
 * Created by hest0 on 2017/7/3.
 */

// (1000-1000+2*(-100-10)-100)*1
public class 四则运算 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			System.out.print(calculate(sc.nextLine()));
		}
		sc.close();
	}

	private static int calculate(String strExp) {
		String exp = strExp.replaceAll("\\[", "(").replaceAll("\\]", ")").replaceAll("\\{", "(").replaceAll("\\}", ")");
		ArrayList<String> strList = getStringList(exp);// string转换为list
		System.out.println(strList.toString());

		ArrayList<String> postOrder = getPostOrder(strList);
		System.out.println(postOrder.toString());

		Integer res = calculate(postOrder);
		return res;// 计算
	}

	private static ArrayList<String> getStringList(String str) {
		ArrayList<String> result = new ArrayList<>();
		StringBuilder num = new StringBuilder();
		char pre = '(';
		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			// 数字和减号
			if (Character.isDigit(c) || c == '-') {
				// "数字-"或者")-"，这种模式的都是减号
				if (c == '-' && (Character.isDigit(pre) || pre == ')')) {// 判断是减号
					// num赋值给result，清空上次循环的结果
					if (num.length() != 0) {
						result.add(num.toString());
						num.setLength(0);
					}
					result.add(String.valueOf(str.charAt(i)));
				} else {// 普通数字或者数字的符号
					num.append(c);
				}
				// 非数字和减号
			} else {
				// num赋值给result，清空上次循环的结果
				if (num.length() != 0) {
					result.add(num.toString());
					num.setLength(0);
				}
				result.add(String.valueOf(str.charAt(i)));
			}
			// 前一个字符
			pre = c;
		}
		// num赋值给result，清空最后一次循环的结果
		if (num.length() != 0) {
			result.add(num.toString());
			num.setLength(0);
		}
		return result;
	}

	// 比较运算符优先级
	private static boolean compare(String peek, String cur) {
		if ("*".equals(peek) && ("/".equals(cur) || "*".equals(cur) || "+".equals(cur) || "-".equals(cur)))
			return true;
		else if ("/".equals(peek) && ("/".equals(cur) || "*".equals(cur) || "+".equals(cur) || "-".equals(cur)))
			return true;
		else if ("+".equals(peek) && ("+".equals(cur) || "-".equals(cur)))
			return true;
		else if ("-".equals(peek) && ("+".equals(cur) || "-".equals(cur)))
			return true;
		return false;
	}

	// 将中缀表达式转为后缀表达式
	private static ArrayList<String> getPostOrder(ArrayList<String> inOrderList) {
		ArrayList<String> result = new ArrayList<>();
		Stack<String> stack = new Stack<>();
		for (String s : inOrderList) {
			// 首字符是数字和减号直接加入
			if (Character.isDigit(s.charAt(0)) || (s.length() > 1 && s.charAt(0) == '-')) {
				result.add(s);
			} else {
				// 对首字符分支选择
				switch (s.charAt(0)) {
				case '(':
					stack.push(s);
					break;
				case ')':
					// peek查看栈顶元素，遇到")",退栈到"(",加入result不能加入括号
					while (!stack.peek().equals("(")) {
						result.add(stack.pop());
					}
					stack.pop();
					break;
				default:
					// 遇到了符号先把栈清空，并且保证s的优先级<stack.peek()的优先级
					while (!stack.isEmpty() && compare(stack.peek(), s)) {
						result.add(stack.pop());
					}
					stack.push(s);
					break;
				}
			}
		}
		// 把栈里面的数据赋值给result
		while (!stack.isEmpty()) {
			result.add(stack.pop());
		}
		return result;
	}

	// 计算后缀表达式
	private static Integer calculate(ArrayList<String> postOrder) {
		Stack<Integer> stack = new Stack<>();
		for (String s : postOrder) {
			// 首字符是数字或"-"开始的
			if (Character.isDigit(s.charAt(0)) || (s.length() > 1 && s.charAt(0) == '-')) {
				stack.push(Integer.parseInt(s));
			} else {
				Integer back = stack.pop();
				Integer front = stack.pop();
				Integer res = 0;
				switch (s.charAt(0)) {
				case '+':
					res = front + back;
					break;
				case '-':
					res = front - back;
					break;
				case '*':
					res = front * back;
					break;
				case '/':
					res = front / back;
					break;
				}
				stack.push(res);
			}
		}
		return stack.pop();
	}
}
